using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameScene : MonoBehaviour
{
    // Start is called before the first frame update
    private int N = 16;
    public GameObject[] gameObjects;
    private PrimitiveType[] primTypes = new PrimitiveType[]{PrimitiveType.Sphere, PrimitiveType.Sphere, PrimitiveType.Sphere};
    private Material[] materials;

    private void init()
    {

        materials = new Material[3];
        materials[0] = Resources.Load("H1_mat", typeof(Material)) as Material;
        materials[1] = Resources.Load("H2_mat", typeof(Material)) as Material;
        materials[2] = Resources.Load("H3_mat", typeof(Material)) as Material;

        gameObjects = new GameObject[N * N];

        float itvl = 3f;
        for (int i = 0; i < N ; i++)
        {
            for (int j = 0; j < N ; j++)
            {
                //for(int k = 0;k < N;k++)
                //{
                    int idx = i * N  + j;
                    gameObjects[idx] = GameObject.CreatePrimitive(primTypes[UnityEngine.Random.Range(0, 3)]);
                    gameObjects[idx].transform.Translate((i - N / 2) * itvl, (j - N / 2) * itvl, 0);
                    gameObjects[idx].transform.Rotate(UnityEngine.Random.Range(0.0f, 180.0f),
                        UnityEngine.Random.Range(0.0f, 180.0f), UnityEngine.Random.Range(0.0f, 180.0f));
                    gameObjects[idx].GetComponent<Renderer>().material = materials[UnityEngine.Random.Range(0, 3)];
                //}
                
            }
        }
    }
    void Start()
    {//
        init();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

}
